Arduino: Relays

Opens and closes a circuit that’s “air-gapped” from the Arduino, allowing you to open/close circuits of much higher voltages (like 120V). Not sure how how good of an idea that is, considering the quality of these boards.

DEVICENANO
DC++5V
DC-Ground
IND2

On the other side, “COM” is the positive “input”. “NO” is “normally open” and “NC” is “normally closed”.

//Opens and closes relay

#define RELAY_PIN 2     // Sets pin connect to relay as D2

void setup() {
  // initialize digital pin 9 as an output.
  pinMode(RELAY_PIN, OUTPUT);
}

void loop() {
  digitalWrite(RELAY_PIN, HIGH);
  delay(1000);
  digitalWrite(RELAY_PIN, LOW);
  delay(1000);
}

This entry was posted in Arduino and tagged . Bookmark the permalink.